package com.freak.neteasecloudmusic.modules.find.recommend.base.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.freak.neteasecloudmusic.R;
import com.freak.neteasecloudmusic.modules.find.recommend.base.entity.NewAlbumEntity;
import com.freak.neteasecloudmusic.modules.find.recommend.base.entity.RecommendnewSongEntity;

import java.util.List;

public class NewSongAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {
    private Context context;
    public final static int NEW_SONG_ITEM = 0;
    public final static int NEW_ALBUM_ITEM = 1;
    public NewSongAdapter(List<MultiItemEntity> data, Context context) {
        super(data);
        this.context = context;
        addItemType(NEW_SONG_ITEM, R.layout.view_item_new_song);
        addItemType(NEW_ALBUM_ITEM, R.layout.view_item_new_song);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MultiItemEntity item) {
        switch (helper.getItemViewType()) {
            case NEW_SONG_ITEM:
                RecommendnewSongEntity.ResultBean resultBean = (RecommendnewSongEntity.ResultBean) item;
                Glide.with(context).load(resultBean.getPicUrl()).into((ImageView) helper.getView(R.id.circularBeadClipPathImageViewNewSongItemBg));
                helper.setText(R.id.textViewNewSongItemSongInfo, resultBean.getSong().getName());
                helper.setText(R.id.textViewNewSongItemContext, resultBean.getSong().getName());
                break;
            case NEW_ALBUM_ITEM:
                NewAlbumEntity.AlbumsBean newAlbumEntity= (NewAlbumEntity.AlbumsBean) item;
                Glide.with(context).load(newAlbumEntity.getPicUrl()).into((ImageView) helper.getView(R.id.circularBeadClipPathImageViewNewSongItemBg));
                helper.setText(R.id.textViewNewSongItemSongInfo, newAlbumEntity.getName());
                helper.setText(R.id.textViewNewSongItemContext, newAlbumEntity.getArtist().getName());
                break;
        }

    }
}
